import os
import datamodel

from google.appengine.ext import webapp
from google.appengine.ext import db
from google.appengine.dist import use_library


class Index(webapp.RequestHandler):
  def get(self):
    self.redirect("admin/index.html")

class DeleteAll(webapp.RequestHandler):
  def get(self):
    for trip in datamodel.Trip().all():
        trip.delete()
    for area in datamodel.Area().all():
        area.delete()
    for hotel in datamodel.Hotel().all():
        hotel.delete()
    for hotellink in datamodel.HotelLink().all():
        hotellink.delete()
        
    self.redirect("index.html")

class Init(webapp.RequestHandler):
  def get(self):
    for link in datamodel.LinkConfig().all():
        link.delete()
    link = datamodel.LinkConfig()
    link.name = 'homepage'
    link.iconPath = 'http://www.google.com/options/icons/igoogle.gif'
    link.searchText = ''
    link.customSearchID = '010024046293440985307:aipixq3a-2u'
    link.put()

    link = datamodel.LinkConfig()
    link.name = 'bookingCom'
    link.iconPath = 'http://www.booking.com/favicon.ico'
    link.homepage = 'http://www.booking.com'
    link.searchText = 'site:booking.com'
    link.forwardDateFormat = ';checkin_monthday=STARTDATE_D;checkin_year_month=STARTDATE_YYYY-STARTDATE_M;checkout_monthday=ENDDATE_D;checkout_year_month=ENDDATE_YYYY-ENDDATE_M'
    link.customSearchID = '010024046293440985307:jolexdmm-ya'
    link.put()

    link = datamodel.LinkConfig()
    link.name = 'hotelsCom'
    link.iconPath = 'http://www.hotels.com/favicon.ico'
    link.homepage = 'http://www.hotels.com'
    link.searchText = 'site:hotels.com'
    link.customSearchID = '010024046293440985307:5-xkyxuqne4'
    link.put()

    link = datamodel.LinkConfig()
    link.name = 'tripadvisorCom'
    link.iconPath = 'http://www.tripadvisor.com/favicon.ico'
    link.homepage = 'http://www.tripadvisor.com'
    link.searchText = 'site:tripadvisor.com'
    link.customSearchID = '010024046293440985307:gm2bkdb0ldi'
    link.put()
        
    self.redirect("index.html")
